#!/bin/tcsh -ef
#############################################################################
#                                                                           #
# Title: AUX-Fetch FREALIGN results	                    		    		#
#                                                                           #
# (C) 2dx.org, GNU Plublic License.                                         #
#                                                                           #
# Created..........: 29/07/2016                                             #
# Last Modification: 29/07/2016                                             #
# Author...........: 2dx.org                                                #
#                                                                           #
#############################################################################
#
# SORTORDER: 160
#
#
# MANUAL: This script fetches all the MRC and PAR files within a FREALIGN refinement directory and makes them available from the 2dx GUI.
#
# DISPLAY: SPR_DIR
# DISPLAY: SPR_FRL_DIR
#
#$end_local_vars

set SPR_FRL_DIR = ""

set SPR_DIR = ""
set SPR_FREALIGN_DIR = ${SPR_DIR}/FREALIGN
set SPR_FRL_DIR = ${SPR_FREALIGN_DIR}/${SPR_FRL_DIR}

set scriptname = FetchFREALIGNResults

#$end_vars

if ( -e LOGS/${scriptname}.results ) then
	mv LOGS/${scriptname}.results LOGS/${scriptname}.results.old
endif

foreach i (${SPR_FRL_DIR}/*.mrc)
	echo "# IMAGE-IMPORTANT: $i <MAP: `basename $i`>" >> LOGS/${scriptname}.results
end

foreach i (${SPR_FRL_DIR}/*.par)
	echo "# IMAGE: $i <PAR: `basename $i`>" >> LOGS/${scriptname}.results
end

foreach i (${SPR_FRL_DIR}/scratch/*map*.mrc)
	echo "# IMAGE: $i <MAP: `basename $i`>" >> LOGS/${scriptname}.results
end

echo ":: "
echo ":: Done!"
echo ":: "
